package com.norteksoft.erm.model;

import java.util.HashSet;
import java.util.Set;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
 * 功能权限委托（更新相对更频繁）
 * 
 * @hibernate.class table="ERM_FUNDELEGATE"
 * @author Jiffy
 * 
 */
public class FuncDelegate extends BaseObject {

	private static final long serialVersionUID = 1655763839839256627L;

	private Long OID = new Long(-1);

	private String delegateFrom;// 委托人（用户名），每次查数据库时应主动检查委托人是否有委托权限

	private Set delegateTos=new HashSet();// 受托人（可能有1～n个）

	private Resource resource;// 对应的功能资源

	public int hashCode() {
		return new HashCodeBuilder().append(OID).append(delegateFrom)
				.toHashCode();
	}

	/**
	 * @hibernate.id column="OID" unsaved-value="-1" type="long"
	 * @hibernate.generator class="sequence"
	 * @hibernate.param name="sequence" value="ERM_SEQUENCE"
	 */
	public Long getOID() {
		return OID;
	}

	public void setOID(Long oid) {
		OID = oid;
	}

	/**
	 * @hibernate.property column="DELEGATEFROM" length="60" type="string"
	 *                     not-null="true"
	 * @return String
	 */
	public String getDelegateFrom() {
		return delegateFrom;
	}

	public void setDelegateFrom(String delegateFrom) {
		this.delegateFrom = delegateFrom;
	}

	/**
	 * @hibernate.property column="DELEGATETOS" length="1000"
	 *                     type="com.norteksoft.erm.util.hibernate.usertype.RegularStrSetAsJSON"
	 *                     not-null="true"
	 * @return Set
	 */
	public Set getDelegateTos() {
		return delegateTos;
	}

	public void setDelegateTos(Set delegateTos) {
		this.delegateTos = delegateTos;
	}

	/**
	 * @hibernate.many-to-one name="resource" column="RSID"
	 *                        class="com.norteksoft.erm.model.Resource"
	 */
	public Resource getResource() {
		return resource;
	}

	public void setResource(Resource resource) {
		this.resource = resource;
	}

}
